package study.day2;

public class Demo2 {
    public static void main(String[] args) {
        //拍手游戏
        int teacher,stu1,stu2;
        teacher=stu1=stu2=1;
        int time=0,num=1;//num:观众听到的拍手的次数
        boolean flag;
        do{
            flag=false;
            time++;
            if(teacher<10){
                teacher++;
                flag=true;
            }
            if(stu1<10 && time%2==0){
                stu1++;
                flag=true;
            }
            if(stu2<10 && time%4==0){
                stu2++;
                flag=true;
            }
            if(flag){
                num++;
            }
        }while(teacher+stu1+stu2<30);
        System.out.println("观众听到的掌声次数为："+num);
    }
}
